﻿<%@ WebHandler Language="C#" Class="download" %>

using System;
using System.Web;
using System.IO;
using VioletDevelopmentLaboratory.Net.Web;

public class download : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
		if (context == null)
		{
			throw new ArgumentNullException("context");
		}

		String fileFullPath = context.Request.QueryString["file"];

		if (!String.IsNullOrEmpty(fileFullPath))
		{
			FileInfo file = new FileInfo(fileFullPath);

			if (file.Exists)
			{
				context.Response.ContentType = "Application/UnKnown";
				context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + context.Server.UrlEncode(file.Name));
				context.Response.TransmitFile(file.FullName);
			}
		}
		else
		{
			context.Response.ContentType = "text/html";
			context.Response.Write("File Not Found.");
		}
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}